#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void Comparison(char* e1, char* e2, size_t width)
{
	int x = 0;
	for (x = 0; x < width; x++)
	{
		char a = *e1;
		*e1 = *e2;
		*e2 = a;
		e1++;
		e2++;
	}
}
void my_qsort(void* best, size_t sz, size_t width, int (*p)(const void* e1, const void* e2))
{
	int x = 0;
	for (x = 0; x < sz - 1; x++)
	{
		int y = 0;
		for (y = 0; y < sz - 1 - x; y++)
		{
			if (p((char*)best + y * width, (char*)best + (y + 1) * width) > 0)
			{
				Comparison((char*)best + y * width, (char*)best + (y + 1) * width,width);
			}
		}
	}
}
int p(const void* e1, const void* e2)
{
	return (*(int*)e1 > *(int*)e2) - (*(int*)e1 < *(int*)e2);
}
int main()
{
	int arr[] = { 9,6,3,8,5,2,7,4,1,0 };
	size_t sz = sizeof(arr) / sizeof(arr[0]);
	my_qsort(arr, sz, sizeof(arr[0]), p);
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);

	}
	return 0;
}